package day08.thread02.stopThread;

/**
 * <>
 * <详细描述>
 *
 * @Author WANG.SONG.
 * @Date 2019/3/3 0003 21:42
 * @see
 */
public class Run2 {

    public static void interrupt(){
        InterruptThread interruptThread =new InterruptThread();
        interruptThread.start();
        try {
            Thread.sleep(2000);
            interruptThread.interrupt();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("end");
    }
    /**
     *<此方法最优>
     *@param
     *
     *@return
     *@Author WANG.SONG.
     */
    public static void exception(){
        ExceptionThread interruptThread =new ExceptionThread();
        interruptThread.start();
        try {
            Thread.sleep(2000);
            interruptThread.interrupt();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("end");
    }

    public static void sleep(){

        try {
            SleepThread sleepThread=new SleepThread();
            sleepThread.start();
            Thread.sleep(200);
            sleepThread.interrupt();
        } catch (InterruptedException e) {
            System.out.println("main catch");
            e.printStackTrace();
        }

    }

    public static void returnThread(){
        try {
            ReturnThread returnThread = new ReturnThread();
            returnThread.start();
            Thread.sleep(2000);
            returnThread.interrupt();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    public static void main(String[] args) {
        //Run2.interrupt();
        Run2.exception();
        //Run2.sleep();
        //Run2.returnThread();
    }
}
